<template>
  <div class="app-container">
    <div class="filter-container">
      <p style="float:left;margin-top:5px;margin-left:2%">发布状态：</p>
      <el-select
        size="small"
        placeholder="请选择"
        clearable
        class="filter-item"
        style="width: 250px;margin-left:2%"
        v-model="listQuery.status"
      >
        <el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
      </el-select> 
      <el-button
        size="small"
        class="filter-item"
        type="success"
        icon="el-icon-search"
        style="margin-left:3%"
        @click="handleFilter"
      >
        搜索
      </el-button>
      <el-button
        size="small"
        class="filter-item"
        style="margin-left: 10px;"
        type="primary"
        icon="el-icon-edit"
        @click="handleCreate"
      >添加</el-button>
    </div>

    <el-table
      v-loading="listLoading"
      :key="tableKey"
      :data="list"
      size="small"
      border
      fit
      highlight-current-row
      style="width: 100%;margin-top:1%"
    >
    <el-table-column type="index">
    </el-table-column>
      <el-table-column label="发布地址" min-width="250px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.pubAddr=='firstPage'?'首页':scope.row.pubAddr=='marry'?'易婚庆':scope.row.pubAddr=='job'?'易就业':scope.row.pubAddr=='travel'?'易旅游':scope.row.pubAddr=='edu'?'易教育':scope.row.pubAddr=='special'?'易农特':scope.row.pubAddr=='science'?'易农科':scope.row.pubAddr=='handyService'?'生活服务':scope.row.pubAddr=='profit'?'轻松赚':'' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="发布时间" width="200px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.publishTime }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" width="100px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.status=='0'?'已下架':scope.row.status=='1'?'已发布':scope.row.status=='2'?'待发布':'' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="专栏图标" width="200px" align="center">
        <template slot-scope="scope">
          <!-- <span>{{ scope.row.phoneNumber }}</span> -->
          <img :src="scope.row.imgUrl" style="width:200px;height:200px" alt="">
        </template>
      </el-table-column>
      <el-table-column label="专栏标题" width="200px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.title }}</span>
        </template>
      </el-table-column>
      <el-table-column label="专栏副标题" width="200px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.subTitle }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        width="400px"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="{ row }">
          <el-button
            size="small"
            align="center"
            type="danger"
            plain
            v-if="row.status=='1' || row.status=='2'"
            @click="handleChange(row)"
          >
            {{row.status=='1'?"下架":row.status=='2'?"发布":""}}
          </el-button>
          <!-- <el-button
            size="small"
            align="center"
            type="primary"
            plain
            v-if="row.status=='1' || row.status=='2'"
            @click="handleUpdate(row)"
          >
            编辑
          </el-button> -->
          <el-button
            size="small"
            align="center"
            plain
            type="success"
            v-if="row.status=='1' || row.status=='2'"
            @click="handleAppend(row)"
          >
            添加
          </el-button>
          <el-button
            size="small"
            align="center"
            type="primary"
            @click="handleExamine(row)"
          >
            查看详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="listQuery.pageNum"
      :limit.sync="listQuery.pageSize"
      @pagination="getList"
    />
    <el-dialog
      :close-on-click-modal="false"
      :title="textMap[dialogStatus]"
      :visible.sync="dialogFormVisible"
      append-to-body
      @close="loadPage"
    >
      <el-form
        ref="dataForm"
        :rules="rules"
        :model="temp"
        label-position="left"
        label-width="150px"
        style="width: 700px; margin-left:50px;"
      >
        <el-form-item label="发布地址">
          <el-input v-model="temp.pubAddr" :disabled="true"/>
        </el-form-item>
        <el-form-item label="专栏标题">
          <el-input v-model="temp.title" :disabled="dialogStatus == 'examine' || dialogStatus ==='append' ? true : false"/>
        </el-form-item>
        <el-form-item label="专栏小标题">
          <el-input v-model="temp.subTitle" :disabled="dialogStatus == 'examine' || dialogStatus ==='append' ? true : false"/>
        </el-form-item>
         <el-form-item label="楼层排序">
          <el-input v-model="temp.orders" :disabled="dialogStatus == 'examine' || dialogStatus ==='append' ? true : false"/>
        </el-form-item>
        <el-form-item label="标题图标：">
            <el-upload
              :disabled="dialogStatus === 'examine'|| dialogStatus ==='append' ? true : false"
              class="avatar-uploader"
              action="http://10.0.0.123:10001/ids/pub/file/uploadFile"
              :show-file-list="false"
              :http-request="customRequest"
              v-model="temp.imgUrl">
              <img v-if="temp.imgUrl" :src="temp.imgUrl" class="avatar">  
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
        </el-form-item>
       <el-form-item label="发布时间">
            <el-radio-group v-model="radio" @change="fabuDate" :disabled="dialogStatus == 'examine' || dialogStatus ==='append' ? true : false">
                <el-radio :label="1">即时发布</el-radio>
                <el-radio :label="2">定时发布：<el-date-picker v-model="temp.publishTime" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker></el-radio>
            </el-radio-group>
        </el-form-item>
        <el-form-item label="专栏内容：">
            <el-select
                :disabled="dialogStatus == 'examine' ? true : false"
                size="small"
                placeholder="请选择"  
                clearable
                class="filter-item"
                style="width: 250px;margin-left:2%"
                v-model="selectRefType"
            >
                <el-option v-for="item in channelTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
            </el-select> 
        </el-form-item>
      </el-form>
      <el-form label-position="left" label-width="150px" v-if="selectRefType=='jobOffersId'" :model="dynamicValidateForm3" style="width: 800px;margin-left:50px" ref="dynamicValidateForm3" class="demo-dynamic">
        <el-form-item
          v-for="(domain, index) in dynamicValidateForm3.domains"
          :label="'岗位' + index+':'"
          :key="domain.key"
          >
          <v-selectpage
            :disabled="dialogStatus == 'examine' ? true : false"
            :data="sample1"
            key-field="id"
            v-model="domain.reletionId"
            show-field="name"
            style="width:350px;float:left;height:40px"
          >
          </v-selectpage> 
          <div style="float:left;margin-left:2%" class="clearfix">
            <el-upload
                class="avatar-uploader"
                :disabled="dialogStatus == 'examine' ? true : false"
                action="http://10.0.0.74:8090/uploadImgUrl"
                :show-file-list="false"
                :http-request="customRequest1"
                v-model="domain.imageUrl">
                <div v-if="domain.imageUrl">
                    <img :src="domain.imageUrl" class="avatar">
                </div>
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>  
            </el-upload>
            </div>
          <el-button type="warning" style="float:left;margin-top:-3px;margin-left:2%" @click.prevent="removeDomain3(domain)"><i class="el-icon-remove-outline"></i></el-button>
        </el-form-item>
        <el-form-item>
          <el-button style="margin-left:0px" @click="addDomain3"><i class="el-icon-circle-plus-outline" ></i></el-button>
        </el-form-item>
    </el-form>
    <el-form label-width="150px" label-position="left" v-if="selectRefType=='jobCatId'" :model="dynamicValidateForm2" style="width: 800px;margin-left:50px" ref="dynamicValidateForm2" class="demo-dynamic">
        <el-form-item
          v-for="(domain, index) in dynamicValidateForm2.domains"
          :label="'工种' + index+':'"
          :key="domain.key"
          >
          <v-selectpage
            :disabled="dialogStatus == 'examine' ? true : false"
            :data="profession"
            key-field="id"
            v-model="domain.reletionId"
            show-field="name"
            style="width:350px;float:left;height:40px"
          >
          </v-selectpage> 
          <div style="float:left;margin-left:2%" class="clearfix">
            <el-upload
                :disabled="dialogStatus == 'examine' ? true : false"
                class="avatar-uploader"
                action="http://10.0.0.74:8090/uploadImgUrl"
                :show-file-list="false"
                :http-request="customRequest2"
                v-model="domain.imageUrl">
                <div v-if="domain.imageUrl">
                    <img :src="domain.imageUrl" class="avatar">
                </div>
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>  
            </el-upload>
            </div>
          <el-button type="warning" style="float:left;margin-top:-3px;margin-left:2%" @click.prevent="removeDomain2(domain)"><i class="el-icon-remove-outline"></i></el-button>
        </el-form-item>
        <el-form-item>
          <el-button style="margin-left:0px" @click="addDomain2"><i class="el-icon-circle-plus-outline" ></i></el-button>
        </el-form-item>
    </el-form>
    <el-form label-width="150px" label-position="left" v-if="selectRefType=='jobComId'" :model="dynamicValidateForm" style="width: 800px;margin-left:50px" ref="dynamicValidateForm" class="demo-dynamic">
        <el-form-item
          v-for="(domain, index) in dynamicValidateForm.domains"
          :label="'企业' + index+':'"
          :key="domain.key"
          >
          <v-selectpage
            :disabled="dialogStatus == 'examine' ? true : false"
            :data="sample"
            key-field="id"
            v-model="domain.reletionId"
            show-field="name"
            style="width:350px;float:left;height:40px"
          >
          </v-selectpage>
           <div style="float:left;margin-left:2%" class="clearfix">
            <el-upload
                :disabled="dialogStatus == 'examine' ? true : false"
                class="avatar-uploader"
                action="http://10.0.0.74:8090/uploadImgUrl"
                :show-file-list="false"
                :http-request="customRequest3"
                v-model="domain.imageUrl">
                <div v-if="domain.imageUrl">
                    <img :src="domain.imageUrl" class="avatar">
                </div>
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>  
            </el-upload>
            </div> 
          <el-button type="warning" style="float:left;margin-top:-3px;margin-left:2%" @click.prevent="removeDomain(domain)"><i class="el-icon-remove-outline"></i></el-button>
        </el-form-item>
        <el-form-item>
          <el-button style="margin-left:0px" @click="addDomain"><i class="el-icon-circle-plus-outline" ></i></el-button>
        </el-form-item>
    </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">
          返回
        </el-button>
        <el-button
          type="primary"
          v-if="dialogStatus === 'create' || dialogStatus === 'update' || dialogStatus === 'append'"
          @click="dialogStatus === 'create' ? createData() : dialogStatus === 'append'?appendData():updateData()"
        >
          确定
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
// 异步请求 delLly
import { getListPage,getPubList,getEnterprise,getProfession,updateFloor,updateStatus,addFloor,appendFloor } from '@/api/specialColumn'
import Vue from 'vue'
import {addImg} from '@/api/headWheel'
import { parseTime } from '@/utils'
import Pagination from '@/components/Pagination' // 分页插件
import { SelectPage } from 'v-selectpage'

const calendarTypeOptions = [
  { key: '0', display_name: '已下架' },
  { key: '1', display_name: '已发布' },
  { key: '2', display_name: '待发布' },
]
const channelTypeOptions = [
  { key: 'jobOffersId', display_name: '招聘岗位' },
  { key: 'jobCatId', display_name: '工种分类' },
  { key: 'jobComId', display_name: '用工企业' }
]
const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
  acc[cur.key] = cur.display_name
  return acc
}, {})
const channelTypeKeyValue = channelTypeOptions.reduce((acc, cur) => {
  acc[cur.key] = cur.display_name
  return acc
}, {})

export default {
  inject:["reload"],
  components: { Pagination ,'v-selectpage': SelectPage},

  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'info',
        deleted: 'danger'
      }
      return statusMap[status]
    },
    typeFilter(type) {
      return calendarTypeKeyValue[type]
    },
    channelTypeFilter(type) {
      return channelTypeKeyValue[type]
    }
  },
  data() {
    return {
      radio1:0,
      radio:1,
      sample: [
      ],
      sample1:[],
      profession:[],
      channelTypeOptions,
      deptValue:'',
      tableKey: 0,
      list: null,
      total: 0,
      dynamicValidateForm: {
        domains: [{
          reletionId: '',
          // imageUrl:''
        }],
      },
      dynamicValidateForm2: {
        domains: [{
          reletionId: '',
        }],
      },
      dynamicValidateForm3: {
        domains: [{
          reletionId: '',
        }],
      },
      listLoading: true,
      listQuery: {
        pageNum: 0,
        pageSize: 10,
        sort: '+id',
        status:''
      },
      deps:[],
      sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
      statusOptions: ['published', 'draft', 'deleted'],
      showReviewer: false,
      temp: {
        id: undefined,
        pubAddr:'job',
        datas:[]
      },
      dialogFormVisible: false,
      calendarTypeOptions,
      dialogStatus: '',
      textMap: {
        update: '编辑',
        create: '添加',
        examine: '查看详情',
        append: '添加'
      },
      rowId:"",
      selectRefType:'',
      dialogPvVisible: false,
      outerVisible: false,
      pvData: [],
      rules: {
        type: [{ required: true, message: 'type is required', trigger: 'change' }],
        timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
        title: [{ required: true, message: 'title is required', trigger: 'blur' }]
      },
      downloadLoading: false,
      liaUser: null,
      ids:[],
      select:null,
      allInfo:[],
      detailsImg:[],
      gongzhongImg:[],
      qiyeImg:[],
      jobComReletionId:[],
      jobCatReletionId:[],
      jobOffersReletionId:[],
      jobComImg:[],
      jobCatImg:[],
      jobOffersImg:[],
      qiyeId:[],
      gongzhongId:[],
      gangweiId:[],
      tempImg:''
    }
  },
  created() {
    this.getList()
  },
  methods: {
    loadPage(){
      this.reload()
    },
    fabuDate(){
        // console.log(this.radio)
        if(this.radio===1){
            this.temp.publishTime=''
        }else if(this.radio===2){
            return this.temp.publishTime
        }
    },
    customRequest (data) {
      const formData = new FormData()
      formData.append('file', data.file)
      this.saveFile(formData)
    },
    saveFile (formData) {
      addImg(formData).then(res=>{
        // this.imageUrl=res.data
        this.temp.imgUrl=res.data.filePath
        // console.log(this.temp.imgUrl)
      })
    },
    customRequest2(data){
        const formData = new FormData()
        formData.append('file', data.file)
        this.saveFile2(formData)
    },
    saveFile2 (formData) {
      addImg(formData).then(res=>{
        // this.imageUrl=res.data
        this.gongzhongImg.push(res.data.filePath)
        for( var i=0;i<this.gongzhongImg.length;i++){
          // this.dynamicValidateForm2.domains[i].push(Object.assign({img:this.showImgList[i]}))
          this.$set(this.dynamicValidateForm2.domains[i],'imageUrl',this.gongzhongImg[i])
        }
      })
    },
     customRequest3(data){
        const formData = new FormData()
        formData.append('file', data.file)
        this.saveFile3(formData)
    },
    saveFile3 (formData) {
      addImg(formData).then(res=>{
        // this.imageUrl=res.data
        this.qiyeImg.push(res.data.filePath)
        for( var i=0;i<this.qiyeImg.length;i++){
          // this.dynamicValidateForm2.domains[i].push(Object.assign({img:this.showImgList[i]}))
          this.$set(this.dynamicValidateForm.domains[i],'imageUrl',this.qiyeImg[i])
          // this.dynamicValidateForm.domains[i].imageUrl=this.qiyeImg[i]
        }
      })
    },
    customRequest1 (data) {
      const formData = new FormData()
      formData.append('file', data.file)
      this.saveFile1(formData)
    },
    saveFile1 (formData) {
      addImg(formData).then(res=>{
        // this.imageUrl=res.data
        this.detailsImg.push(res.data.filePath)
        for( var i=0;i<this.detailsImg.length;i++){
          // this.dynamicValidateForm2.domains[i].push(Object.assign({img:this.showImgList[i]}))
          this.$set(this.dynamicValidateForm3.domains[i],'imageUrl',this.detailsImg[i])
        }
      })
    },
    // getgongzhongList(){
    //   getgongzhong().then(res=>{
    //     console.log(res)
    //   })
    // },
    removeDomain3(item) {
      var index = this.dynamicValidateForm3.domains.indexOf(item)
      if (index !== -1) {
        this.dynamicValidateForm3.domains.splice(index, 1)
      }
    },
    addDomain3() {
      this.dynamicValidateForm3.domains.push({
        
      });
    },
    removeDomain2(item) {
      var index = this.dynamicValidateForm2.domains.indexOf(item)
      if (index !== -1) {
        this.dynamicValidateForm2.domains.splice(index, 1)
      }
    },
    addDomain2() {
      this.dynamicValidateForm2.domains.push({
      });
    },
    removeDomain(item) {
      var index = this.dynamicValidateForm.domains.indexOf(item)
      if (index !== -1) {
        this.dynamicValidateForm.domains.splice(index, 1)
      }
    },
    addDomain() {
      this.dynamicValidateForm.domains.push({
      });
    },
    getProfessionList(){
      getProfession().then(res=>{
        this.profession=res.data
      })
    },
    getEnterpriseList(){
      getEnterprise().then(res=>{
        this.sample=res.data
        console.log(this.sample)
      })
    },
    getAllPub(){
      var params={
        pageNum:0,
        pageSize:100000
      }
      getPubList(params).then(res=>{
        this.sample1=res.data.content
      })
    },
    getList() {
      this.listLoading = true
      var params = {
        // pageConvert: true,
        pageNum: this.listQuery.pageNum,
        pageSize: this.listQuery.pageSize,
        // realName:this.listQuery.realName,
        // phoneNumber:this.listQuery.phoneNumber
        status: this.listQuery.status,
        pubAddr: 'job'
      }
      getListPage(params).then(response => {
        this.list = response.data.content
        // console.log(this.list)
        this.total = response.data.totalElements
        // console.log(this.total)
        // Just to simulate the time of the request
          this.listLoading = false
      })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    handleModifyStatus(row, status) {
      this.$message({
        message: '操作成功',
        type: 'success'
      })
      row.status = status
    },
    sortChange(data) {
      const { prop, order } = data
      if (prop === 'id') {
        this.sortByID(order)
      }
    },
    sortByID(order) {
      if (order === 'ascending') {
        this.listQuery.sort = '+id'
      } else {
        this.listQuery.sort = '-id'
      }
      this.handleFilter()
    },
    resetTemp() {
      this.temp = {
        id: undefined
      }
    },
    handleExamine(row){
        this.dialogStatus='examine'
        this.dialogFormVisible = true
        this.temp = Object.assign({}, row)
        for(var i=0;i<this.temp.datas.length;i++){
        if(this.temp.datas[i].refType=='jobComId'){
          this.jobComReletionId.push(this.temp.datas[i].reletionId)
          this.jobComImg.push(this.temp.datas[i].imageUrl)
          this.selectRefType='jobComId'
        }else if(this.temp.datas[i].refType=='jobCatId'){
          this.jobCatReletionId.push(this.temp.datas[i].reletionId)
          this.jobCatImg.push(this.temp.datas[i].imageUrl)
          this.selectRefType='jobCatId'
        }else if(this.temp.datas[i].refType=='jobOffersId'){
          this.jobOffersReletionId.push(this.temp.datas[i].reletionId)
          this.jobOffersImg.push(this.temp.datas[i].imageUrl)
          this.selectRefType='jobOffersId'
        }
      }
      for(var i=0;i<this.jobComReletionId.length;i++){
        this.qiyeId.push((Object.assign({reletionId:this.jobComReletionId[i],imageUrl:this.jobComImg[i],refType:'jobComId'})))
        console.log(this.dynamicValidateForm) 
      }
      this.dynamicValidateForm.domains=this.qiyeId
      for(var i=0;i<this.jobCatReletionId.length;i++){
        this.gongzhongId.push((Object.assign({reletionId:this.jobCatReletionId[i],imageUrl:this.jobCatImg[i],refType:'jobCatId'})))
      }
      this.dynamicValidateForm2.domains=this.gongzhongId
      for(var i=0;i<this.jobOffersReletionId.length;i++){
        this.gongzhongId.push((Object.assign({reletionId:this.jobOffersReletionId[i],imageUrl:this.jobOffersImg[i],refType:'jobOffersId'})))
      }
      this.dynamicValidateForm3.domains=this.gangweiId
    },
    //  handleUpdate(row) {
    //   this.getEnterpriseList()
    //   this.getProfessionList()
    //   this.getAllPub()
    //   this.dialogStatus = 'update'
    //   this.temp = Object.assign({}, row) // copy obj
    //   console.log(this.temp.datas)
    //   for(var i=0;i<this.temp.datas.length;i++){
    //     if(this.temp.datas[i].refType=='jobComId'){
    //       this.jobComReletionId.push(this.temp.datas[i].reletionId)
    //       this.jobComImg.push(this.temp.datas[i].imageUrl)
    //       this.selectRefType='jobComId'
    //     }else if(this.temp.datas[i].refType=='jobCatId'){
    //       this.jobCatReletionId.push(this.temp.datas[i].reletionId)
    //       this.jobCatImg.push(this.temp.datas[i].imageUrl)
    //       this.selectRefType='jobCatId'
    //     }else if(this.temp.datas[i].refType=='jobOffersId'){
    //       this.jobOffersReletionId.push(this.temp.datas[i].reletionId)
    //       this.jobOffersImg.push(this.temp.datas[i].imageUrl)
    //       this.selectRefType='jobOffersId'
    //     }
    //   }
    //   for(var i=0;i<this.jobComReletionId.length;i++){
    //     this.qiyeId.push((Object.assign({reletionId:this.jobComReletionId[i],imageUrl:this.jobComImg[i],refType:'jobComId'})))
    //     console.log(this.dynamicValidateForm) 
    //   }
    //   this.dynamicValidateForm.domains=this.qiyeId
    //   for(var i=0;i<this.jobCatReletionId.length;i++){
    //     this.gongzhongId.push((Object.assign({reletionId:this.jobCatReletionId[i],imageUrl:this.jobCatImg[i],refType:'jobCatId'})))
    //   }
    //   this.dynamicValidateForm2.domains=this.gongzhongId
    //   for(var i=0;i<this.jobOffersReletionId.length;i++){
    //     this.gongzhongId.push((Object.assign({reletionId:this.jobOffersReletionId[i],imageUrl:this.jobOffersImg[i],refType:'jobOffersId'})))
    //   }
    //   this.dynamicValidateForm3.domains=this.gangweiId
    //   // this.temp.timestamp = new Date(this.temp.timestamp)
    //   this.dialogFormVisible = true
    //   this.$nextTick(() => {
    //     this.$refs['dataForm'].clearValidate()
    //   })
    // },
    // updateData() {
    //   for(var i=0;i<this.temp.datas.length;i++){
    //     if(this.temp.datas[i].refType=='jobOffersId'){
    //       this.temp.datas=this.dynamicValidateForm3.domains
    //     }else if(this.temp.datas[i].refType=='jobCatId'){
    //       this.temp.datas=this.dynamicValidateForm2.domains
    //     }else if(this.temp.datas[i].refType=='jobComId'){
    //       console.log(this.dynamicValidateForm.domains)
    //       this.temp.datas=this.dynamicValidateForm.domains
    //     }
    //   }
    //     // this.temp.refIds=this.refId
    //   if(this.radio===1){
    //     this.temp.publishTime=''
    //   }else if(this.radio===2){
    //     return this.temp.publishTime
    //   }
    //   // console.log(this.temp.publishTime)
    //   const tempData = Object.assign({}, this.temp)
    //   // console.log(tempData)
    //   updateFloor(tempData).then(() => {
    //     for (const v of this.list) {
    //       if (v.id === this.temp.id) {
    //         const index = this.list.indexOf(v)
    //         this.list.splice(index, 1, this.temp)
    //         break
    //       }
    //     }
    //     this.dialogFormVisible = false
    //     this.$notify({
    //       title: '成功',
    //       message: '修改成功',
    //       type: 'success',
    //       duration: 2000
    //     })
    //   this.reload()
    //   })
    // },
    handleChange(row){
        this.rowId=row.floorId
        this.temp = Object.assign({}, row)
        if(this.temp.status=='2'){
            this.temp.status='1'
        }else if(this.temp.status=='1'){
            this.temp.status='0'
        }
        var params={
            id:this.rowId,
            status:this.temp.status
        }
        updateStatus(params).then(res=>{
            this.$notify({
                title: '成功',
                message: '修改成功',
                type: 'success',
                duration: 2000
            })
            this.reload()
        })
    },
    handleCreate() {
      this.resetTemp()
      this.getEnterpriseList()
      this.getProfessionList()
      this.getAllPub()
      this.dialogStatus = 'create'
      this.temp.pubAddr='job'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
    },
    handleAppend(row){
      this.rowId=row.floorId
      this.resetTemp()
      this.getEnterpriseList()
      this.getProfessionList()
      this.getAllPub()
      this.temp = Object.assign({}, row)
      console.log(this.temp)
      this.dialogStatus = 'append'
      this.temp.pubAddr='job'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
    },
    appendData(){
      if(this.selectRefType=='jobOffersId'){
        for(var i=0;i<this.dynamicValidateForm3.domains.length;i++){
          this.$set(this.dynamicValidateForm3.domains[i],'refType','jobOffersId')
          this.$set(this.dynamicValidateForm3.domains[i],'floorId',this.rowId)
        }
          this.temp.datas=this.dynamicValidateForm3.domains
          console.log(this.dynamicValidateForm3.domains)
        }else if(this.selectRefType=='jobCatId'){
          for(var i=0;i<this.dynamicValidateForm2.domains.length;i++){
            this.$set(this.dynamicValidateForm2.domains[i],'refType','jobCatId')
            this.$set(this.dynamicValidateForm2.domains[i],'floorId',this.rowId)
          }
          this.temp.datas=this.dynamicValidateForm2.domains
        }else if(this.selectRefType=='jobComId'){
          for(var i=0;i<this.dynamicValidateForm.domains.length;i++){
            this.$set(this.dynamicValidateForm.domains[i],'refType','jobComId')
            this.$set(this.dynamicValidateForm.domains[i],'floorId',this.rowId)
          }
          console.log(this.dynamicValidateForm.domains)
          this.temp.datas=this.dynamicValidateForm.domains
        }
      if(this.radio===1){
        this.temp.publishTime=''
      }else if(this.radio===2){
        var aa=this.temp.publishTime.trim().split(/\s+/)
        this.temp.publishTime=aa[0]+'T'+aa[1]
      }
      appendFloor(this.temp.datas).then(() => {
        this.list.unshift(this.temp.datas)
        this.dialogFormVisible = false
        this.$notify({
          title: '成功',
          message: '添加成功',
          type: 'success',
          duration: 2000
        })
        this.reload()
      })
    },
    createData() {
      if(this.selectRefType=='jobOffersId'){
        for(var i=0;i<this.dynamicValidateForm3.domains.length;i++){
          this.$set(this.dynamicValidateForm3.domains[i],'refType','jobOffersId')
          this.$set(this.dynamicValidateForm3.domains[i],'floorId',this.rowId)
        }
          this.temp.datas=this.dynamicValidateForm3.domains
          console.log(this.dynamicValidateForm3.domains)
        }else if(this.selectRefType=='jobCatId'){
          for(var i=0;i<this.dynamicValidateForm2.domains.length;i++){
            this.$set(this.dynamicValidateForm2.domains[i],'refType','jobCatId')
            this.$set(this.dynamicValidateForm2.domains[i],'floorId',this.rowId)
          }
          this.temp.datas=this.dynamicValidateForm2.domains
        }else if(this.selectRefType=='jobComId'){
          for(var i=0;i<this.dynamicValidateForm.domains.length;i++){
            this.$set(this.dynamicValidateForm.domains[i],'refType','jobComId')
            this.$set(this.dynamicValidateForm.domains[i],'floorId',this.rowId)
          }
          console.log(this.dynamicValidateForm.domains)
          this.temp.datas=this.dynamicValidateForm.domains
        }
      if(this.radio===1){
        this.temp.publishTime=''
      }else if(this.radio===2){
        var aa=this.temp.publishTime.trim().split(/\s+/)
        this.temp.publishTime=aa[0]+'T'+aa[1]
      }
      addFloor(this.temp).then(() => {
        this.list.unshift(this.temp)
        this.dialogFormVisible = false
        this.$notify({
          title: '成功',
          message: '添加成功',
          type: 'success',
          duration: 2000
        })
        this.reload()
      })

    },
    getSortClass: function(key) {
      const sort = this.listQuery.sort
      return sort === `+${key}`
        ? 'ascending'
        : sort === `-${key}`
          ? 'descending'
          : ''
    }
  }
}
</script>
<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 100px;
    height: 100px;
    line-height: 100px;
    text-align: center;
  }
  .avatar {
    width: 100px;
    height: 100px;
    display: block;
  }
</style>
